﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using System.IO;
using WeiTalk.Controls;

namespace WeiTalk
{
    public partial class ImageViewerPage : PhoneApplicationPage
    {
        public static WeiBoControl ParentControl { get; set; }

        public ImageViewerPage()
        {
            InitializeComponent();
        }

        public static Stream Source
        {
            set;
            get;
        }

        public static bool IsGif
        {
            get;
            set;
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            picViewer.ImageSource = Source;
            picViewer.IsGif = IsGif;
            sbWeiBoContent.Content = CopyWeiBo();
        }

        private WeiBoControl CopyWeiBo()
        {
            WeiBoControl weiBo = new WeiBoControl();
            weiBo.Name = Guid.NewGuid().ToString();
            weiBo.Id = ParentControl.Id;
            weiBo.RetweetedThumbnailPic = ParentControl.RetweetedThumbnailPic;
            weiBo.Text = ParentControl.Text;
            weiBo.UserId = ParentControl.UserId;
            weiBo.UserName = ParentControl.UserName;
            weiBo.CreatedAt = ParentControl.CreatedAt;
            weiBo.ProfileImageUrl = ParentControl.ProfileImageUrl;
            weiBo.RetweetedCommentCount = ParentControl.RetweetedCommentCount;
            if (ParentControl.ThumbnailPic != null)
            {
                weiBo.ThumbnailPic = ParentControl.ThumbnailPic;
            }
            weiBo.RetweetedContent = ParentControl.RetweetedContent;
            weiBo.RetweetedId = ParentControl.RetweetedId;
            weiBo.RetweetedSource = ParentControl.RetweetedSource;

            weiBo.RetweetedUserId = ParentControl.RetweetedUserId;
            weiBo.RetweetedUserName = ParentControl.RetweetedUserName;
            weiBo.RetweetedRepostsCount = ParentControl.RetweetedRepostsCount;
            weiBo.Source = ParentControl.Source;
            weiBo.CommentCount = ParentControl.CommentCount;
            weiBo.RepostsCount = ParentControl.RepostsCount;
            return weiBo;
        }
    }
}